package com.example.translator;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class BatchTranslationTest {
    public static void main(String[] args) {
        try {
            System.out.println("=== 批量翻译功能测试 ===");

            // 创建翻译服务实例
            TranslationService translationService = new LangChain4jTranslationService();

//            // 检查配置
//            if (!translationService.isConfigured()) {
//                System.err.println("配置不正确，请检查config.properties文件");
//                return;
//            }

            // 测试测试文件名列表
            List<String> testFileNames = Arrays.asList(
                    "user_authentication_system",
                    "data_analysis_report_2024",
                    "financial_dashboard_design",
                    "network_security_protocol",
                    "customer_feedback_analysis",
                    "sales_performance_metrics",
                    "inventory_management_system",
                    "employee_training_manual",
                    "product_development_timeline",
                    "market_research_summary"
            );

            System.out.println("测试文件名列表:");
            for (int i = 0; i < testFileNames.size(); i++) {
                System.out.println((i + 1) + ". " + testFileNames.get(i));
            }

            // 执行批量翻译
            long startTime = System.currentTimeMillis();
            TranslationService.ProgressCallback callback = null;
            Map<String, String> results = translationService.batchTranslateFileNames(testFileNames,callback);
            long endTime = System.currentTimeMillis();

            System.out.println("\n批量翻译完成，耗时: " + (endTime - startTime) + "ms");
            System.out.println("\n翻译结果:");

            // 显示翻译结果
            for (Map.Entry<String, String> entry : results.entrySet()) {
                System.out.println(entry.getKey() + " -> " + entry.getValue());
            }

            // 验证结果
            if (results.size() == testFileNames.size()) {
                System.out.println("\n✓ 所有文件都已翻译");
            } else {
                System.err.println("\n✗ 翻译结果不完整，预期 " + testFileNames.size() + " 个结果，实际 " + results.size() + " 个");
            }

        } catch (Exception e) {
            System.err.println("测试失败: " + e.getMessage());
            e.printStackTrace();
        }
    }
}
